<template>
  <div>
    <el-button type="text" @click="to">编辑</el-button>
    <eForm ref="form" :sup_this="sup_this" :is-add="false" :dicts="dicts" />
  </div>
</template>
<script>
import eForm from './form'
export default {
  components: {
    eForm
  },
  props: {
    data: {
      type: Object,
      required: true
    },
    // index.vue 的this 可用于刷新数据
    sup_this: {
      type: Object,
      required: true
    },
    dicts: {
      type: Array,
      required: true
    }
  },
  methods: {
    to() {
      const _this = this.$refs.form
      _this.getDepts()
      _this.getRoleLevel()
      _this.roleIds = []
      _this.form = {
        userName: this.data.userName,
        realname: this.data.realname,
        telephone: this.data.telephone,
        email: this.data.email,
        state: this.data.state,
        roles: [],
        dept: {
          deptId: this.data.dept.deptId
        }
      }
      this.data.roles.forEach(function(data, index) {
        _this.roleIds.push(data.merchantRoleId)
      })
      _this.deptId = this.data.dept.deptId
      _this.getRoles()
      _this.dialog = true
    }
  }
}
</script>

<style scoped>
  div {
    display: inline-block;
    margin-right: 3px;
  }

</style>
